// 配置路由
import Vue from 'vue'
import VueRouter from 'vue-router'
// 一级路由
import Login from '@/views/login'
import Register from '@/views/register'
import Layout from '@/views/layout'
// 二级路由
import HomePage from '@/views/homePage'
import News from '@/views/news'
import Search from '@/views/search'
import User from '@/views/user'
import Collect from '@/views/collect'
import MyRent from '@/views/myRent'

Vue.use(VueRouter)

const router = new VueRouter({
  routes: [
    { path: '/login', component: Login },
    { path: '/register', component: Register },
    { path: '/collect', component: Collect },
    { path: '/myrent', component: MyRent },
    {
      path: '/',
      component: Layout,
      redirect: '/user',
      children: [
        {
          path: '/user',
          component: User
        },
        {
          path: '/homepage',
          component: HomePage
        },
        {
          path: '/search',
          component: Search
        },
        {
          path: '/news',
          component: News
        }
      ]
    }
  ]
})

export default router
